<template>
	<view class="content">
		<!-- 这里的autowire-query-name、autowire-list-name都可以写在全局配置中，实际上项目中只要写<z-paging ref="paging">即可 -->
		<!-- autowire-list-name用于设置自动赋值list的名字，autowire-query-name用于设置自动调用query方法的方法名 -->
		<z-paging ref="paging" autowire-list-name="dataList" autowire-query-name="getservicecode">
			<!-- 需要固定在顶部不滚动的view放在slot="top"的view中，如果需要跟着滚动，则不要设置slot="top" -->
			<view>
				<!-- 注意！此处的z-tabs为独立的组件，可替换为第三方的tabs，若需要使用z-tabs，请在插件市场搜索z-tabs并引入，否则会报插件找不到的错误 -->
				<z-tabs :list="tabList" @change="tabChange" />
			</view>
			<!-- 如果希望其他view跟着页面滚动，可以放在z-paging标签内 -->
			<view>
				<block v-if="dataList && dataList.length>0 || dataList.length>0">
					<!-- <z-paging ref="paging" v-model="dataList" @query="getList"></z-paging> -->
					<scroll-view scroll-y="true" class="scroll-Y" :show-scrollbar="false">
						<JobManageItem v-for="(item,index) in dataList" :key="index" :data="item" @btnClick="btnClick" @jobItemClick = "jobItemClick">
						</JobManageItem>
					</scroll-view>
				</block>
				<block v-if="dataList && dataList.length == 0 && dataList.length == 0">
					<view class="empty-img">
						<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/icon50.png"></image>
						<label>暂无内容</label>
					</view>
				</block>
				<view class="item-line"></view>
			</view>
		</z-paging>
	</view>


</template>
<script>
	import Index from "@/common/index-model.js"
	let index = new Index()
	let that = null
	export default {
		data() {
			return {
				state: "-1",
				tabList: ['全部', '审核通过', '审核失败', '已下线'],
				indexs: [-1, 1, 2, 3],
				tabIndex: 0,
				dataList: [],
				code: "",
				showcode: false,
				entId:''
			};
		},
		// watch: {
		// 	state() {
		// 		// this.getservicecode();
		// 		this.$refs.paging.reload();
		// 	},
		// },
		methods: {
			itemClick(item) {
				console.log('点击了', item.title);
			},
			tabChange(index) {
				this.tabIndex = index;
				this.state = this.indexs[index]
				console.log('点击切换', index, this.state)
				//当切换tab或搜索时请调用组件的reload方法，请勿直接调用：queryList方法！！
				this.$refs.paging.reload();
			},
			btnClick(data) {
				console.log('点到我了---', data.type, data.data.id)
				if (data.type == 1) {
					//好活下线
					index.getPublicUserMember({}, 'client/recuitjob/outline/' + data.data.id, 'PUT', res => {
						console.log('点到我了---', res)
						if (res.data.code == 200) {
							uni.showToast({
								title: "好活已下线"
							})
							this.getservicecode()
							uni.setStorageSync('fromPage', 'deljob'); // 存储来源信息
						}
					})
				} else if (data.type == 4) {
					//好活删除
					index.getPublicUserMember({}, 'client/recuitjob/remove/' + data.data.id, 'PUT', res => {
						console.log('点到我了---', res)
						if (res.data.code == 200) {
							uni.showToast({
								title: "好活已删除"
							})
							this.getservicecode()
							uni.setStorageSync('fromPage', 'deljob'); // 存储来源信息
						}
					})
				} else if (data.type == 5) {
					//好活重新上线
					index.getPublicUserMember({}, 'client/recuitjob/reonline/' + data.data.id, 'post', res => {
						console.log('点到我了---', res)
						if (res.data.code == 200) {
							uni.showToast({
								title: "好活重新上线"
							})
							this.getservicecode()
							uni.setStorageSync('fromPage', 'deljob'); // 存储来源信息
						}
					})
					this.getservicecode()
				} else if (data.type == 2) {
					//查看报名列表
					console.log('查看报名列表---', data)
					uni.navigateTo({
						url: "/pagesC/entryList/entryList?orderId=" + data.data.id
					})
				} else if(data.type == 3) {
					console.log("编辑",data)
					let setdata = JSON.stringify(data)
					uni.navigateTo({
						url: "/pagesC/job/issuejob?setdata=" + setdata
					})
				}
			},
			jobItemClick(data){
				// console.log(data.data)
				if(data.data.status == 1){
					uni.navigateTo({
						url: "/pagesB/jobinfo/jobLeavetwoInfo?cardID=" + data.data.id
					})
				}
				// if(data.data.status == 2){
				// 	console.log("未过")
				// }
				
			},
			cardClick({
				data
			}) {

			},
			collectClick({
				data
			}) {
				uni.navigateTo({
					url: "/pages/course/detail?id=" + data.id
				});
			},
			getservicecode(pageNo, pageSize) {
				console.log('分页数据====', pageNo, pageSize)
				let url = "client/recuitjob/userRecuitJobList"
				let data = {}

				if (this.state == -1) {
					data = {
						entId:this.entId,
						pageNum: pageNo,
						pageSize: pageSize,
						userId: uni.getStorageSync('userid')
					}
				} else {
					data = {
						entId:this.entId,
						pageNum: pageNo,
						pageSize: pageSize,
						userId: uni.getStorageSync('userid'),
						status: this.state
					}
				}
				console.log("请求参数", data);
				index.getPublicUserMember(data, url, 'get', res => {
					console.log("请求结果", res);
					if (res.data.code == 200 && res.data.success) {
						// this.dataList = res.data.result.records;
						this.$refs.paging.complete(res.data.result.records);

					}
				})
			},
			to() {

			},
			toQikan(id) {

			},
		},
		onLoad(options) {
			this.entId = options.entId
			this.getservicecode();
			// this.getList();
		},
	};
</script>
<style lang="scss" scoped>
	.itemCell {
		margin-bottom: 5px;
	}

	.course {
		.tabs {
			display: flex;
			background: #fff;
			padding: 0 40rpx;
			justify-content: space-between;

			view {
				height: 100rpx;
				line-height: 100rpx;
				position: relative;

				&.active {
					&::before {
						display: block;
						content: "";
						background: #d5b675;
						width: 88rpx;
						height: 4rpx;
						position: absolute;
						left: 50%;
						transform: translateY(-50%);
						margin-left: -40rpx;
						bottom: 0;
					}
				}
			}
		}

		.list {
			.item {
				margin: 20rpx;

				.info {
					display: flex;
					position: relative;
					height: 186rpx;
					color: #9a6835;
					align-items: center;

					image {
						width: 100%;
						height: 186rpx;
						position: absolute;
						top: 0;
						left: 0;
					}

					.left {
						margin-left: 45rpx;
						position: relative;
						z-index: 1;
						padding-right: 30rpx;
						padding-top: 20rpx;
						padding-bottom: 10rpx;
						margin-right: 24rpx;
						border-right: 1px dashed #9a6835;

						.price {
							font-size: 40rpx;

							text {
								font-size: 30rpx;
							}
						}
					}

					.min {
						flex: 1;
						position: relative;
						z-index: 1;
						font-size: 24rpx;
					}

					.right {
						margin-right: 35rpx;
						position: relative;
						z-index: 1;
						font-size: 36rpx;
					}
				}

				.detail {
					background: #fcf9f0;
					padding: 30rpx 20rpx;
					line-height: 48rpx;
					color: #8c8c8c;
				}

				&.colorgary {
					.info {
						color: #8c8c8c;
					}

					.left {
						border-right: 1px dashed #8c8c8c;
					}
				}
			}
		}

		.showCont {
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			z-index: 999;
			background: rgba($color: #000000, $alpha: 0.5);

			image {
				width: 100%;
				height: 700rpx;
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
			}

			.code {
				width: 120rpx;
				height: 120rpx;
				position: absolute;
				top: 52%;
				left: 50%;
				// margin-top: -50rpx;
				// margin-left: -50rpx;
				transform: translate(-50%, -50%);
			}

			.close {
				position: absolute;
				top: 72%;
				left: 50%;
				transform: translateX(-50%);
				width: 60rpx;
				height: 60rpx;
			}
		}
	}

	.list {
		margin: 30rpx;

		.item {
			display: flex;
			background: #fff;
			border-radius: 20rpx;
			overflow: hidden;
			margin-bottom: 20rpx;

			image.left {
				width: 210rpx;
				height: 190rpx;
				margin-right: 20rpx;
			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				margin: 16rpx 0;

				.t1 {
					font-size: 30rpx;
					font-weight: bold;
				}

				.tips {
					font-size: 28rpx;
					color: #666666;

					text {
						background: #fde7c7;
						color: #996633;
						border-radius: 30rpx;
						padding: 0 10rpx;
						display: inline-block;
						margin-left: 10rpx;
					}
				}

				.t2 {
					display: flex;
					align-items: center;
					font-size: 28rpx;
					color: #666666;

					image {
						width: 30rpx;
						height: 30rpx;
						margin-right: 10rpx;
					}
				}
			}
		}
	}

	.contentLab {
		overflow: hidden;
		-webkit-line-clamp: 2;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.lineview {
		background-color: #F6F6F6;
		width: 100%;
		height: 5px;
	}

	.centerview {
		margin: 10px;
		background-color: white;
		// margin-top: 15px;
		// margin-: 15px;
	}

	.buttomview {
		margin-left: 10px;
		padding-bottom: 10px;
		background-color: white;
		display: flex;
		flex-direction: row;
		height: 45px;

		.addr {
			display: flex;
			flex-direction: column;
			color: #a1a1a1;
			font-size: 24rpx;
			// margin-top: 20rpx;
			width: 65%;
			// ::v-deep {
			// 	.u-icon {
			// 		margin-right: 60px;
			// 	}
			// }
		}

		.callview {
			// background-color: #a1a1a1;
			// padding: 15px;
			margin-top: 15px;
			height: 30px;
			// margin-left: 150px;
			width: 35%;

			.callbtn {
				// margin-right: 15px;
				// width: 80px;
				// height: 30px;
				// font-size: 13px;
				// // margin: auto;
				// text-align: center;
				// // letter-spacing: 3px;
				// // text-indent: 3px;
				// writing-mode: vertical-lr;
				margin-top: -10rpx;
				height: 60rpx;
				line-height: 60rpx;
				width: 180rpx;
				text-align: center;
				color: #fff;
				border-radius: 8rpx;
				background: #0575ff;
				font-size: 28rpx;

			}
		}
	}
</style>
<style>
	@import url("@/static/css/publics.css");
</style>